package com.example.administrator.wallet.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.administrator.wallet.R;
import com.example.administrator.wallet.model.bean.GatheringGetListBean;
import com.example.administrator.wallet.view.activity.mine.Personal.ReceiptInformation.ReceiptInformationActivity;

import java.util.List;

/**
 * Effect:
 * <p>
 * Author:  CaiYapeng
 * <p>
 * Time  :  2018/7/12.
 */

public class ReceiptInformationAdapter extends BaseAdapter {
    private Context context;
    private List<GatheringGetListBean.DataBean> datas1;
    private OnClick click;

    public ReceiptInformationAdapter(ReceiptInformationActivity receiptInformationActivity, List<GatheringGetListBean.DataBean> datas1) {
        this.context = receiptInformationActivity;
        this.datas1= datas1;
    }

    @Override
    public int getCount() {
        return datas1.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        final ViewHolder holder;
        if (view == null) {
            holder = new ViewHolder();
            view = View.inflate(context, R.layout.item_contact, null);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.iv_head = (ImageView) view.findViewById(R.id.iv_head);
        holder.tv_contact = (TextView) view.findViewById(R.id.tv_contact);
        holder.mRl_all = (RelativeLayout) view.findViewById(R.id.rl_all);

        Glide.with(context).load(datas1.get(i).getIcon()).into(holder.iv_head);
        holder.tv_contact.setText(datas1.get(i).getName() + "  (" + datas1.get(i).getAccount()+")");


        holder.mRl_all.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ReceiptInformationAdapter.this.click.Click(datas1.get(i));
            }
        });
        return view;
    }

    public interface OnClick {
        void Click(GatheringGetListBean.DataBean dataBean);
    }
    public void getClickPst(OnClick click) {
        this.click = click;
    }
    public class ViewHolder {
        public ImageView iv_head;//标志
        public TextView tv_contact;//收款类别
        public RelativeLayout mRl_all;
    }
}
